if (pfn & foreign_map_pfn) {
t = PFN_TYPE_FOREIGN;
mfn = foreign_to_mfn(d, pfn);
- } else if (pfn >= max_page && pfn < (max_page + NR_GRANT_FRAMES)) {
+ } else if (pfn >= max_page && pfn <
+ (max_page + nr_grant_frames(d->grant_table))) {
+ /* XXX access d->grant_table->nr_grant_frames without lock.
+ * Currently on powerpc dynamic expanding grant table is
+ * inhibited by setting max_nr_grant_frames = INITIAL_NR_GRANT_FRAMES
+ * so that this access is safe.
+ */
/* Its a grant table access */
t = PFN_TYPE_GNTTAB;
mfn = gnttab_shared_mfn(d, d->grant_table, (pfn - max_page));
ulong gnttab_mfn;
ulong rma_mfn;
+ /* XXX access d->grant_table->nr_grant_frames without lock.
+ * Currently on powerpc dynamic expanding grant table is
+ * inhibited by setting max_nr_grant_frames = INITIAL_NR_GRANT_FRAMES
+ * so that this access is safe.
+ */
/* grant? */
gnttab_mfn = gnttab_shared_mfn(d, d->grant_table, 0);
- if (mfn >= gnttab_mfn && mfn < (gnttab_mfn + NR_GRANT_FRAMES))
+ if (mfn >= gnttab_mfn && mfn <
+ (gnttab_mfn + nr_grant_frames(d->grant_table)))
return max_page + (mfn - gnttab_mfn);
/* IO? */
#include <xen/domain_page.h>
#include <acm/acm_hooks.h>
+#ifndef max_nr_grant_frames
unsigned int max_nr_grant_frames = DEFAULT_MAX_NR_GRANT_FRAMES;
integer_param("gnttab_max_nr_frames", max_nr_grant_frames);
+#endif
/* The maximum number of grant mappings is defined as a multiplier of the
* maximum number of grant table entries. This defines the multiplier used.
#include <asm/powerpc64/config.h>
+/*
+ * Disallow grant table growing tempralily because pfn2mfn() and
+ * mfn_to_gmfn() depends on the fact that grant table is machine-address
+ * contiguous. Grant table growing breaks the assumption.
+ */
+#ifndef max_nr_grant_frames
+#define max_nr_grant_frames INITIAL_NR_GRANT_FRAMES
+#endif
+
#endif
#define gnttab_create_shared_page(d, t, i) \
do { \
share_xen_page_with_guest( \
- virt_to_page((char *)(t)->shared + ((i) * PAGE_SIZE)), \
+ virt_to_page((t)->shared[(i)]), \
(d), XENSHARE_writable); \
} while ( 0 )
-#define gnttab_shared_mfn(d, t, i) (((ulong)((t)->shared) >> PAGE_SHIFT) + (i))
+#define gnttab_shared_mfn(d, t, i) (virt_to_mfn((t)->shared[(i)]))
#define gnttab_shared_gmfn(d, t, i) \
(mfn_to_gmfn(d, gnttab_shared_mfn(d, t, i)))
#define INITIAL_NR_GRANT_ENTRIES ((INITIAL_NR_GRANT_FRAMES << PAGE_SHIFT) / \
sizeof(grant_entry_t))
+#ifndef DEFAULT_MAX_NR_GRANT_FRAMES /* to allow arch to override */
/* Default maximum size of a grant table. [POLICY] */
#define DEFAULT_MAX_NR_GRANT_FRAMES 32
+#endif
+#ifndef max_nr_grant_frames /* to allow arch to override */
/* The maximum size of a grant table. */
extern unsigned int max_nr_grant_frames;
+#endif
/*
* Tracks a mapping of another domain's grant reference. Each domain has a